{% extends "base.html" %}

{%- block title -%}Docs.rs{%- endblock title -%}

{%- block body_classes -%}
centered
{%- endblock body_classes -%}

{%- block topbar -%}
    {%- include "header/topbar.html" -%}
{%- endblock topbar -%}

{%- block body -%}
    <div class="container landing">
        <h1 class="brand">{{ crate::icons::IconCubes.render_solid(false, false, "") }} Docs.rs</h1>

        <form action="/releases/search" method="GET" class="landing-search-form">
            <div>
                <input class="search-input" id="search" name="query" type="text" aria-label="Find crate by search query"
                    placeholder="Type 'S' or '/' to search" autofocus>
            </div>

            <div class="buttons">
                <button type="submit" class="pure-button pure-button-normal">Search</button>
                <button type="submit" class="pure-button pure-button-normal" name="i-am-feeling-lucky" value="1">
                    I'm Feeling Lucky
                </button>
            </div>
        </form>
    </div>

    <div class="container">
        <div class="recent-releases-container">
            <div class="release">
                <a href="/releases">
                    <strong>Recent Releases</strong>
                </a>
                <a href="/releases/feed" title="Atom feed">
                    {{- crate::icons::IconSquareRss.render_solid(false, false, "") -}}
                </a>
            </div>

            <ul>
                {%- for release in recent_releases -%}
                    {%- set release_params = release.rustdoc_params() -%}
                    {% set release_url %}
                    {%- if release.rustdoc_status -%}
                        {%- set release_url = release_params.rustdoc_url() -%}
                    {%- else -%}
                        {%- set release_url = release_params.crate_details_url() -%}
                    {%- endif -%}

                    <li>
                        <a href="{{ release_url|safe }}"
                            class="release">
                            <div class="pure-g">
                                <div class="pure-u-1 pure-u-sm-6-24 pure-u-md-5-24 name">
                                    {{- release.name }}-{{ release.version -}}
                                </div>
                                <div class="pure-u-1 pure-u-sm-14-24 pure-u-md-16-24 description">
                                    {{- release.description.as_deref().unwrap_or_default() -}}
                                </div>

                                {%- if let Some(build_time) = release.build_time -%}
                                    <div class="pure-u-1 pure-u-sm-4-24 pure-u-md-3-24 date" {#- #}
                                        title="{{ build_time.format("%FT%TZ") }}">
                                        {{- build_time|timeformat -}}
                                    </div>
                                {%- endif -%}
                            </div>
                        </a>
                    </li>
                {%- endfor -%}
            </ul>
        </div>
    </div>
{%- endblock body -%}

{%- block javascript -%}
    <script nonce="{{ csp_nonce }}" type="text/javascript" src="/-/static/keyboard.js?{{ build_slug }}"></script>
{%- endblock javascript -%}
